<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>

    function Person2 (name, age) {
      this.name = name;
      this.age = age;
      this.say = function () {
        console.log('说话');
      }
    }
    Person2.prototype.study = function () {
      console.log('Study');
    }
    var p2 = new Person2('李四', 22)
    console.log(p2);
    class Person {
      constructor(name, age) {
        this.name = name;
        this.age = age;
        this.say = function () {
          console.log('说话');
        }
      }
      study () {
        console.log('Study');
      }
      eat () {
        console.log('吃饭');
      }

    }
    var p = new Person('张三', 20);
    console.log(p);
    p.study()
    p.say()
    p.eat()
  </script>
</body>

</html>